﻿using Huasky.MyWrod.Core.Db;

namespace Huasky.MyWrod.Application.Entities;

/// <summary>
/// 种子数据（确保每个上下文有且仅存在一个种子数据类型）
/// </summary>
public class SeedData : ISeedData
{
    public MainDbContext Db { get; set; } = new HuaskyDbContext();


    public void Handle()
    {
        Db.AddRange(new[]
        {
            new OrderEntity { Id = Guid.Parse("96c4c565-2e27-4f46-9d9e-57abfc782e78"), Amount = 22, Code = "20000001", CreatedTime = new DateTime (2024, 2, 3, 5, 6, 7), JsonExt = "{}"},
            new OrderEntity { Id = Guid.Parse("607f4b7a-1980-45b6-920e-155316816dfc"), Amount = 35, Code = "20000002", CreatedTime = new DateTime (2024, 2, 3, 11, 12, 44), JsonExt = "{\"deskName\":\"D03\"}"},
        });

        Db.SaveChanges();
    }

    public void Dispose()
    {
        Db.Dispose();
    }
}
